package com.mz.util;

import java.io.InputStream;
import java.util.Iterator;
import java.util.Map;

public class SendMailUtil {
	public static String getHtmlTemplate(InputStream templateInputStream, Map<String,Object> map) {
		try {
			int size = templateInputStream.available();
			byte[] bs = new byte[size];
			templateInputStream.read(bs);
			templateInputStream.close();

			String strXmlData = new String(bs, "UTF-8");

			for (Iterator<String> it = map.keySet().iterator(); it.hasNext();) {
				String key = (String) it.next();
				strXmlData = strXmlData.replaceAll(key, map.get(key) + "");
			}
			return strXmlData;
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
	}
}
